package com.antler.smt.portal.controller;

import com.antler.smt.entity.AreaEntity;
import com.antler.smt.portal.mapper.AreaInfoMapper;
import com.antler.smt.response.base.Result;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * TODO
 *
 * @author vic
 * @date 2018-04-11 10:20
 *  
 */
@RestController
@RequestMapping(value = "/area")
@Api(description = "国家地区接口")
public class AreaController {

    @Autowired
    AreaInfoMapper areaInfoMapper;

    /**
     * 区域列表
     *
     * @param parentId
     * @return
     */
    @GetMapping("/listArea/{parentId}")
    @ApiOperation(value = "获取区域列表", httpMethod = "GET")
    public Result listArea(@PathVariable Long parentId) {
        DataValidator.isNull(parentId, "区域列表接口，父节点Id不能为空！");
        List<AreaEntity> areas = areaInfoMapper.selectByParentId(parentId);
        return new Result(areas);
    }
}
